using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableFragDao:DaoBase<TableFrag>
    {
        public override void AddPrimaryIndex(TableFrag model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableFrag.txt";
        }

        protected override TableFrag ParseRowData(string[] rowData)
        {
            TableFrag data = new TableFrag();
			data.id = rowData [0];
			data.target = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.num = 0;
            }
            else
            {
                data.num = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.price = 0;
            }
            else
            {
                data.price = int.Parse(rowData[3]);
            }

            return data;
        }


        public override void AddOneIndex(TableFrag model)
        {
            if (!cacheOneIndex.ContainsKey(model.target.ToString()))
            {
                cacheOneIndex[model.target.ToString()] = new List<TableFrag>();
            }
            cacheOneIndex[model.target.ToString()].Add(model);
        }
    

    }

}
